package de.howie.android.logviewer.preferences;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import de.howie.android.logviewer.R;

public class Preferences extends PreferenceActivity {
	SharedPreferences preferences;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		preferences = PreferenceManager.getDefaultSharedPreferences(this);
		setPreferenceScreen(createPreferenceHierarchy());
	}

	private PreferenceScreen createPreferenceHierarchy() {
		PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
        
		 // List preference
        PreferenceCategory prefCatLanguage = new PreferenceCategory(this);
		prefCatLanguage.setTitle(R.string.PrefCatLanguage);
		root.addPreference(prefCatLanguage);
		ListPreference listPref = new ListPreference(this);
        listPref.setEntries(R.array.languages);
		listPref.setEntryValues(R.array.languages);
		listPref.setDialogTitle(R.string.PreferencesIISILanguageSelect);
		listPref.setKey(getResources().getString(R.string.PrefsLanguage));
        listPref.setTitle(R.string.PreferencesIISILanguage);
        prefCatLanguage.addPreference(listPref);
        
	    // Dialog based preferences
	    PreferenceCategory prefCatData = new PreferenceCategory(this);
	    prefCatData.setTitle(R.string.PrefCatData);
	    root.addPreference(prefCatData);
	    PreferenceScreen intentData = getPreferenceManager().createPreferenceScreen(this);
	    intentData.setIntent(new Intent(Preferences.this, PreferencesData.class));
	    intentData.setTitle(R.string.PrefCatDataTitle);
	    intentData.setSummary(R.string.PrefCatDataSummary);
	    prefCatData.addPreference(intentData);       
	    
        return root;
	}
   
	@Override
	public void onBackPressed() {
		finish();
	    }
	
	@Override
	public void onResume() {
	 super.onResume();
	}
	
	@Override
	public void onDestroy() {
	 super.onDestroy();
	}

}
